package sjtu.ist.warehouse4ws.service;

import java.util.List;

import sjtu.ist.warehouse4ws.dao.DomainEpcDao;
import sjtu.ist.warehouse4ws.dao.DomainEpcDaoHibernate;
import sjtu.ist.warehouse4ws.dao.cust.CustDomainEpcDao;
import sjtu.ist.warehouse4ws.model.CustDomainEpc;
import sjtu.ist.warehouse4ws.model.DomainEpc;
import sjtu.ist.warehouse4ws.tool.Constants;
import sjtu.ist.warehouse4ws.tool.PropertyHelper;

public class DomainEpcServiceImpl implements DomainEpcService{
	private DomainEpcDao domainEpcDao;
	private CustDomainEpcDao custDomainEpcDao;

	public void setDomainEpcDao(DomainEpcDaoHibernate domainEpcDao) {
		this.domainEpcDao = domainEpcDao;
	}

	public void setCustDomainEpcDao(CustDomainEpcDao custDomainEpcDao) {
		this.custDomainEpcDao = custDomainEpcDao;
	}

	@Override
	public void save(DomainEpc domainEpc, int companyId) {
		// TODO Auto-generated method stub
		if(companyId==Constants.ADMIN_COMPANY_ID){
			this.domainEpcDao.save(domainEpc);
		}else{
			CustDomainEpc cde=new CustDomainEpc();
			PropertyHelper.copyProperties(domainEpc, cde);
			custDomainEpcDao.save(cde);
		}
		
	}	

	@Override
	public List find(String uid) {
		// TODO Auto-generated method stub
		return domainEpcDao.find(uid);
	}
}
